package com.blockmeta.bbs.businesslibrary.net.pojo;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.blockmeta.bbs.baselibrary.utils.FormatUtil;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * @author AirThor
 * @date 2019/4/24.
 * 币种f10页面数据
 */
public class F10Response implements Parcelable {

    /**
     * rate : 6.92
     * total_usd : 129462634793
     * exchanges : [{"volume":738371.06,"proportion":36.26,"exchange":"OKEx"},{"volume":260213.16,"proportion":12.78,"exchange":"Huobi"},{"volume":208128.36,"proportion":10.22,"exchange":"Gate.io"},{"volume":206353.61,"proportion":10.13,"exchange":"CoinMex"},{"volume":179246.5,"proportion":8.8,"exchange":"CoinEgg"},{"volume":169406.14,"proportion":8.32,"exchange":"CoinTiger"}]
     * coin_img : https://s2.coinmarketcap.com/static/img/coins/32x32/1866.png
     * ranking : {"volume":"1,809,582","symbol":"BTM","circulating_supply":"1002499275.0","total":"78,964,854","hold_support":true,"github_support":true,"price":"0.078768","change":"1.32","name":"Bytom","index":54,"coin_key":"BTM_Bytom"}
     * pairs : [{"volume":"373046.625686","exist":true,"proportion":"18.32","price":"0.0788489464763","l_pair":"btm_usd","source":"OKEx","l_exchange":"okex","updated":"Spot","pair":"BTM/USDT","coin_key":"BTM","symbol":"btm","currency":"usd"}]
     * info : {"chinese_name":"比原链","coin_name":"Bytom","desc":"bytom blockchain protocol（简称比原链：bytom）是一种多元比特资产的交互协议，运行在比原链区块链上的不同形态的、异构的比特资产（原生的数字货币、数字资产）和原子资产（有传统物理世界对应物的权证、权益、股息、债券、情报资讯、预测信息等）可以通过该协议进行登记、交换、对赌、和基于合约的更具复杂性的交互操作。连通原子世界与比特世界，促进资产在两个世界间的交互和流转。比原链采用三层架构：应用层、合约层、数据层，应用层对移动终端等多终端友好，方便开发者便捷的开发出资产管理应用；合约层采用创世合约和控制合约进行资产的发行和管理，在底层支持扩展的utxo模型butxo，对虚拟机做了优化，采用自省机制以防止图灵完备中的死搀状态；数据层使用分布式账本技术，实现资产的发行、花费、交换等操作，共识机制采用对人工智能asic芯片友好型pow算法，在哈希过程中引入矩阵和卷积计算，使得矿机在闲置或被淘汰后，可用于ai硬件加速服务，从而产生额外的社会效益。","explorer":"https://etherscan.io/token/0xcb97e65f07da24d46bcdd078ebebd7c6e6e3d750","ico_price":"约 $0.04","ico_time":"2017-08-09","symbol":"BTM","total":1407000000,"twitter":"https://twitter.com/Bytom_Official","website":"http://bytom.io/","white_paper":"http://bytom.io/BytomWhitePaperV1.0_Economic.pdf","team":[{"name":"中本聪","photo_url":"mock","bio":"Founder","page":"mock"}],"road_map":[{"date":"2017-11-12","event":"比原链全球巡回Meetup东京站"}]}
     */

    @SerializedName("rate")
    private double rate;
    @SerializedName("total_usd")
    private double totalUsd;
    @SerializedName("coin_img")
    private String coinImg;
    @SerializedName("ranking")
    private RankingBean ranking;
    @SerializedName("info")
    private InfoBean info;
    @SerializedName("exchanges")
    private List<ExchangesBean> exchanges;
    @SerializedName("pairs")
    private List<PairsBean> pairs;

    public double getRate() {
        return rate;
    }

    public double getTotalUsd() {
        return totalUsd;
    }

    public String getCoinImg() {
        return coinImg;
    }

    public RankingBean getRanking() {
        return ranking;
    }

    public InfoBean getInfo() {
        return info;
    }

    public List<ExchangesBean> getExchanges() {
        return exchanges;
    }

    public List<PairsBean> getPairs() {
        return pairs;
    }

    public static class RankingBean implements Parcelable{
        /**
         * volume : 1,809,582
         * symbol : BTM
         * circulating_supply : 1002499275.0
         * total : 78,964,854
         * hold_support : true
         * github_support : true
         * price : 0.078768
         * change : 1.32
         * name : Bytom
         * index : 54
         * coin_key : BTM_Bytom
         */

        @SerializedName("volume")
        private String volume;
        @SerializedName("symbol")
        private String symbol;
        @SerializedName("circulating_supply")
        private String circulatingSupply;
        @SerializedName("total")
        private String total;
        @SerializedName("hold_support")
        private boolean holdSupport;
        @SerializedName("github_support")
        private boolean githubSupport;
        @SerializedName("price")
        private String price;
        @SerializedName("change")
        private String change;
        @SerializedName("name")
        private String name;
        @SerializedName("index")
        private int index;
        @SerializedName("coin_key")
        private String coinKey;

        public String getVolume() {
            return TextUtils.isEmpty(volume)?"0":volume;
        }

        public String getSymbol() {
            return symbol;
        }

        public String getCirculatingSupply() {
            return TextUtils.isEmpty(circulatingSupply)?"0":FormatUtil.notation2String(circulatingSupply);
        }

        public String getTotal() {
            return TextUtils.isEmpty(total)?"1":total;
        }

        public boolean isHoldSupport() {
            return holdSupport;
        }

        public boolean isGithubSupport() {
            return githubSupport;
        }

        public String getPrice() {
            return TextUtils.isEmpty(price)?"0":price;
        }

        public String getChange() {
            return TextUtils.isEmpty(change)?"0":change;
        }

        public String getName() {
            return name;
        }

        public int getIndex() {
            return index;
        }

        public String getCoinKey() {
            return coinKey==null?"":coinKey;
        }


        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.volume);
            dest.writeString(this.symbol);
            dest.writeString(this.circulatingSupply);
            dest.writeString(this.total);
            dest.writeByte(this.holdSupport ? (byte) 1 : (byte) 0);
            dest.writeByte(this.githubSupport ? (byte) 1 : (byte) 0);
            dest.writeString(this.price);
            dest.writeString(this.change);
            dest.writeString(this.name);
            dest.writeInt(this.index);
            dest.writeString(this.coinKey);
        }

        public RankingBean() {
        }

        protected RankingBean(Parcel in) {
            this.volume = in.readString();
            this.symbol = in.readString();
            this.circulatingSupply = in.readString();
            this.total = in.readString();
            this.holdSupport = in.readByte() != 0;
            this.githubSupport = in.readByte() != 0;
            this.price = in.readString();
            this.change = in.readString();
            this.name = in.readString();
            this.index = in.readInt();
            this.coinKey = in.readString();
        }

        public static final Creator<RankingBean> CREATOR = new Creator<RankingBean>() {
            @Override
            public RankingBean createFromParcel(Parcel source) {
                return new RankingBean(source);
            }

            @Override
            public RankingBean[] newArray(int size) {
                return new RankingBean[size];
            }
        };
    }

    public static class InfoBean implements Parcelable {
        /**
         * chinese_name : 比原链
         * coin_name : Bytom
         * desc : bytom blockchain protocol（简称比原链：bytom）是一种多元比特资产的交互协议，运行在比原链区块链上的不同形态的、异构的比特资产（原生的数字货币、数字资产）和原子资产（有传统物理世界对应物的权证、权益、股息、债券、情报资讯、预测信息等）可以通过该协议进行登记、交换、对赌、和基于合约的更具复杂性的交互操作。连通原子世界与比特世界，促进资产在两个世界间的交互和流转。比原链采用三层架构：应用层、合约层、数据层，应用层对移动终端等多终端友好，方便开发者便捷的开发出资产管理应用；合约层采用创世合约和控制合约进行资产的发行和管理，在底层支持扩展的utxo模型butxo，对虚拟机做了优化，采用自省机制以防止图灵完备中的死搀状态；数据层使用分布式账本技术，实现资产的发行、花费、交换等操作，共识机制采用对人工智能asic芯片友好型pow算法，在哈希过程中引入矩阵和卷积计算，使得矿机在闲置或被淘汰后，可用于ai硬件加速服务，从而产生额外的社会效益。
         * explorer : https://etherscan.io/token/0xcb97e65f07da24d46bcdd078ebebd7c6e6e3d750
         * ico_price : 约 $0.04
         * ico_time : 2017-08-09
         * symbol : BTM
         * total : 1407000000
         * twitter : https://twitter.com/Bytom_Official
         * website : http://bytom.io/
         * white_paper : http://bytom.io/BytomWhitePaperV1.0_Economic.pdf
         * team : [{"name":"中本聪","photo_url":"mock","bio":"Founder","page":"mock"}]
         * road_map : [{"date":"2017-11-12","event":"比原链全球巡回Meetup东京站"}]
         */

        @SerializedName("chinese_name")
        private String chineseName;
        @SerializedName("coin_name")
        private String coinName;
        @SerializedName("desc")
        private String desc;
        @SerializedName("explorer")
        private String explorer;
        @SerializedName("ico_price")
        private String icoPrice;
        @SerializedName("ico_time")
        private String icoTime;
        @SerializedName("symbol")
        private String symbol;
        @SerializedName("total")
        private String total;
        @SerializedName("twitter")
        private String twitter;
        @SerializedName("website")
        private String website;
        @SerializedName("white_paper")
        private String whitePaper;
        @SerializedName("team")
        private List<TeamBean> team;
        @SerializedName("road_map")
        private List<RoadMapBean> roadMap;

        public String getChineseName() {
            return chineseName;
        }

        public String getCoinName() {
            return coinName;
        }

        public String getDesc() {
            return desc;
        }

        public String getExplorer() {
            return explorer;
        }

        public String getIcoPrice() {
            return TextUtils.isEmpty(icoPrice)?"/":icoPrice;
        }

        public String getIcoTime() {
            return TextUtils.isEmpty(icoTime)?"/":icoTime;
        }

        public String getSymbol() {
            return symbol;
        }

        public String getTotal() {
            return TextUtils.isEmpty(total)?"0": FormatUtil.notation2String(total);
        }

        public String getTwitter() {
            return twitter;
        }

        public String getWebsite() {
            return website;
        }

        public String getWhitePaper() {
            return whitePaper;
        }

        public List<TeamBean> getTeam() {
            return team;
        }

        public List<RoadMapBean> getRoadMap() {
            return roadMap;
        }

        public static class TeamBean implements Parcelable {
            /**
             * name : 中本聪
             * photo_url : mock
             * bio : Founder
             * page : mock
             */

            @SerializedName("name")
            private String name;
            @SerializedName("photo_url")
            private String photoUrl;
            @SerializedName("bio")
            private String bio;
            @SerializedName("page")
            private String page;

            public String getName() {
                return name;
            }

            public String getPhotoUrl() {
                return photoUrl;
            }

            public String getBio() {
                return bio;
            }

            public String getPage() {
                return page;
            }


            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(this.name);
                dest.writeString(this.photoUrl);
                dest.writeString(this.bio);
                dest.writeString(this.page);
            }

            public TeamBean() {
            }

            protected TeamBean(Parcel in) {
                this.name = in.readString();
                this.photoUrl = in.readString();
                this.bio = in.readString();
                this.page = in.readString();
            }

            public static final Creator<TeamBean> CREATOR = new Creator<TeamBean>() {
                @Override
                public TeamBean createFromParcel(Parcel source) {
                    return new TeamBean(source);
                }

                @Override
                public TeamBean[] newArray(int size) {
                    return new TeamBean[size];
                }
            };
        }

        public static class RoadMapBean implements Parcelable {
            /**
             * date : 2017-11-12
             * event : 比原链全球巡回Meetup东京站
             */

            @SerializedName("date")
            private String date;
            @SerializedName("event")
            private String event;

            public String getDate() {
                return date;
            }

            public String getEvent() {
                return event;
            }


            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(this.date);
                dest.writeString(this.event);
            }

            public RoadMapBean() {
            }

            protected RoadMapBean(Parcel in) {
                this.date = in.readString();
                this.event = in.readString();
            }

            public static final Creator<RoadMapBean> CREATOR = new Creator<RoadMapBean>() {
                @Override
                public RoadMapBean createFromParcel(Parcel source) {
                    return new RoadMapBean(source);
                }

                @Override
                public RoadMapBean[] newArray(int size) {
                    return new RoadMapBean[size];
                }
            };
        }


        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.chineseName);
            dest.writeString(this.coinName);
            dest.writeString(this.desc);
            dest.writeString(this.explorer);
            dest.writeString(this.icoPrice);
            dest.writeString(this.icoTime);
            dest.writeString(this.symbol);
            dest.writeString(this.total);
            dest.writeString(this.twitter);
            dest.writeString(this.website);
            dest.writeString(this.whitePaper);
            dest.writeTypedList(this.team);
            dest.writeTypedList(this.roadMap);
        }

        public InfoBean() {
        }

        protected InfoBean(Parcel in) {
            this.chineseName = in.readString();
            this.coinName = in.readString();
            this.desc = in.readString();
            this.explorer = in.readString();
            this.icoPrice = in.readString();
            this.icoTime = in.readString();
            this.symbol = in.readString();
            this.total = in.readString();
            this.twitter = in.readString();
            this.website = in.readString();
            this.whitePaper = in.readString();
            this.team = in.createTypedArrayList(TeamBean.CREATOR);
            this.roadMap = in.createTypedArrayList(RoadMapBean.CREATOR);
        }

        public static final Creator<InfoBean> CREATOR = new Creator<InfoBean>() {
            @Override
            public InfoBean createFromParcel(Parcel source) {
                return new InfoBean(source);
            }

            @Override
            public InfoBean[] newArray(int size) {
                return new InfoBean[size];
            }
        };
    }

    public static class ExchangesBean implements Parcelable {
        /**
         * volume : 738371.06
         * proportion : 36.26
         * exchange : OKEx
         */

        @SerializedName("volume")
        private double volume;
        @SerializedName("proportion")
        private double proportion;
        @SerializedName("exchange")
        private String exchange;

        public double getVolume() {
            return volume;
        }

        public double getProportion() {
            return proportion;
        }

        public String getExchange() {
            return exchange;
        }


        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeDouble(this.volume);
            dest.writeDouble(this.proportion);
            dest.writeString(this.exchange);
        }

        public ExchangesBean() {
        }

        protected ExchangesBean(Parcel in) {
            this.volume = in.readDouble();
            this.proportion = in.readDouble();
            this.exchange = in.readString();
        }

        public static final Creator<ExchangesBean> CREATOR = new Creator<ExchangesBean>() {
            @Override
            public ExchangesBean createFromParcel(Parcel source) {
                return new ExchangesBean(source);
            }

            @Override
            public ExchangesBean[] newArray(int size) {
                return new ExchangesBean[size];
            }
        };
    }

    public static class PairsBean implements Parcelable {
        /**
         * volume : 373046.625686
         * exist : true
         * proportion : 18.32
         * price : 0.0788489464763
         * l_pair : btm_usd
         * source : OKEx
         * l_exchange : okex
         * updated : Spot
         * pair : BTM/USDT
         * coin_key : BTM
         * symbol : btm
         * currency : usd
         */

        @SerializedName("volume")
        private String volume;
        @SerializedName("exist")
        private boolean exist;
        @SerializedName("proportion")
        private String proportion;
        @SerializedName("price")
        private String price;
        @SerializedName("l_pair")
        private String lPair;
        @SerializedName("source")
        private String source;
        @SerializedName("l_exchange")
        private String lExchange;
        @SerializedName("updated")
        private String updated;
        @SerializedName("pair")
        private String pair;
        @SerializedName("coin_key")
        private String coinKey;
        @SerializedName("symbol")
        private String symbol;
        @SerializedName("currency")
        private String currency;

        public String getVolume() {
            return TextUtils.isEmpty(volume)?"0":volume;
        }

        public boolean isExist() {
            return exist;
        }

        public String getProportion() {
            return TextUtils.isEmpty(proportion)?"0":proportion;
        }

        public String getPrice() {
            return TextUtils.isEmpty(price)?"0":price;
        }

        public String getlPair() {
            return lPair;
        }

        public String getSource() {
            return source;
        }

        public String getlExchange() {
            return lExchange;
        }

        public String getUpdated() {
            return updated;
        }

        public String getPair() {
            return pair;
        }

        public String getCoinKey() {
            return coinKey;
        }

        public String getSymbol() {
            return symbol;
        }

        public String getCurrency() {
            return currency;
        }


        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.volume);
            dest.writeByte(this.exist ? (byte) 1 : (byte) 0);
            dest.writeString(this.proportion);
            dest.writeString(this.price);
            dest.writeString(this.lPair);
            dest.writeString(this.source);
            dest.writeString(this.lExchange);
            dest.writeString(this.updated);
            dest.writeString(this.pair);
            dest.writeString(this.coinKey);
            dest.writeString(this.symbol);
            dest.writeString(this.currency);
        }

        public PairsBean() {
        }

        protected PairsBean(Parcel in) {
            this.volume = in.readString();
            this.exist = in.readByte() != 0;
            this.proportion = in.readString();
            this.price = in.readString();
            this.lPair = in.readString();
            this.source = in.readString();
            this.lExchange = in.readString();
            this.updated = in.readString();
            this.pair = in.readString();
            this.coinKey = in.readString();
            this.symbol = in.readString();
            this.currency = in.readString();
        }

        public static final Creator<PairsBean> CREATOR = new Creator<PairsBean>() {
            @Override
            public PairsBean createFromParcel(Parcel source) {
                return new PairsBean(source);
            }

            @Override
            public PairsBean[] newArray(int size) {
                return new PairsBean[size];
            }
        };
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeDouble(this.rate);
        dest.writeDouble(this.totalUsd);
        dest.writeString(this.coinImg);
        dest.writeParcelable(this.ranking, flags);
        dest.writeParcelable(this.info, flags);
        dest.writeTypedList(this.exchanges);
        dest.writeTypedList(this.pairs);
    }

    public F10Response() {
    }

    protected F10Response(Parcel in) {
        this.rate = in.readDouble();
        this.totalUsd = in.readDouble();
        this.coinImg = in.readString();
        this.ranking = in.readParcelable(RankingBean.class.getClassLoader());
        this.info = in.readParcelable(InfoBean.class.getClassLoader());
        this.exchanges = in.createTypedArrayList(ExchangesBean.CREATOR);
        this.pairs = in.createTypedArrayList(PairsBean.CREATOR);
    }

    public static final Creator<F10Response> CREATOR = new Creator<F10Response>() {
        @Override
        public F10Response createFromParcel(Parcel source) {
            return new F10Response(source);
        }

        @Override
        public F10Response[] newArray(int size) {
            return new F10Response[size];
        }
    };
}
